jQuery(function () {
    function myAjax(categoryLevel, parentId) {
        jQuery.getJSON("/getCategoryByParentId", {"parentId": parentId}, function (msg) {
            jQuery(categoryLevel).empty().append('<option value="-1" selected="selected">请选择...</option>>')
            jQuery("#productCategoryLevel3").empty().append('<option value="-1" selected="selected">请选择...</option>>')
            jQuery(msg).each(function () {
                jQuery(categoryLevel).append('<option value=' + this.id + '>' + this.name + '</option>>')
            });
        })
    }

    jQuery("#productCategoryLevel1").change(function () {
        myAjax("#productCategoryLevel2", this.value);
    });
    jQuery("#productCategoryLevel2").change(function () {
        // alert(this.value)
        myAjax("#productCategoryLevel3", this.value);
    });
})